package org.uoss.applications.framework.dao.util;

import org.springframework.util.Assert;

public final class DynamicDataSourceHolder {
	
	private final static ThreadLocal<String> dataSourceHolder = new ThreadLocal<String>();
	
	public static String getDataSourceByAlias(){
		return dataSourceHolder.get();
	}
	
	public static void setDataSourceAlias(String dataSourceAlias){
		Assert.notNull(dataSourceAlias, "Data source alias can not be null.");
		dataSourceHolder.set(dataSourceAlias);
	}
	
	public static void clearDataSourceAlias(){
		dataSourceHolder.remove();
	}
}
